//企业头部
import React, { Component } from 'react'
import {
    View,
    Text,
    Image,
    TouchableOpacity,
    ImageBackground
} from 'react-native';

import { Homec_Style as styles } from '../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';
import { common_url, fetchRequest } from "../../../util/fetch";

let Dimensions = require('Dimensions');
let width = Dimensions.get('window').width;
let height = Dimensions.get('window').height;

export default class Homec_top extends Component {

    constructor(props) {
        super(props);
        this.state = {
            count: 0,
        };
        this.noReadCountE();
    }

    render() {
        return (
            <View>
                <ImageBackground style={[styles.homeimg, {
                    width: width * 1,
                    height: height * 0.16
                }]} source={require('../../../img/app/zi.jpg')} resizeMode='cover'>

                    <TouchableOpacity activeOpacity={1} style={styles.headimg} onPress={() => {
                        this.props.navigation.navigate('Ccombasic_all', { company: this.props.company })
                    }}>
                        <Image source={
                            this.props.company.companyPicture ?
                                { uri: common_url + "uploadImg/" + this.props.company.companyPicture }
                                : require('../../../img/app/company.png')} style={styles.headall} />
                    </TouchableOpacity>

                    <Text style={styles.top_text}>首页</Text>
                    <View style={styles.top_icon}>

                        <TouchableOpacity style={styles.top_icon2} activeOpacity={1}
                            onPress={() => {
                                this.props.navigation.navigate('Select_c')
                            }}>
                            <Icon
                                name={'ios-search'}
                                size={25}
                                color={'#ffffff'} />
                        </TouchableOpacity>

                        <TouchableOpacity activeOpacity={1} style={styles.top_icon3}
                            onPress={() => {
                                this.props.navigation.navigate('Newsall_c', { noReadCountE: this.noReadCountE.bind(this) })
                            }}>
                            <Icon
                                name={'md-text'}
                                size={25}
                                color={'#ffffff'} />

                        </TouchableOpacity>

                        {this.state.count === 0 || <Text style={styles.numall}>{this.state.count}</Text>}


                    </View>
                </ImageBackground>
            </View>
        )
    }

    noReadCountE() {
        fetchRequest('xzMsg/noReadCountE.go', 'POST', {}).then(
            res => this.setState({ count: res.count })
        );
    }

}